<template>
<div>
  <b-navbar type="light" variant="light">
    <b-form-input class="mr-sm-2" placeholder="Search"></b-form-input>
      <b-button variant="outline-success" class="my-2 my-sm-0" type="submit">Search</b-button>

</b-navbar>
</div>
    <fileUploader></fileUploader>

    <FileList id = "fileList"></FileList>

</template>

<style scoped>
#fileList{
    padding: 20px;
}
</style>

<script setup>
// https://bootstrap-vue.org/docs/components/navbar

import { ref, onMounted } from 'vue'
import { getCurrentInstance } from 'vue'
import { useRouter } from 'vue-router';
import { useStore } from 'vuex'
import { key } from '../store'
import fileUploader from "./components/FileUploader.vue";
import FileList from "./components/FileList.vue";

const app = getCurrentInstance()
const router = useRouter();
const store = useStore(key)
const serverurl = app.appContext.config.globalProperties.$serverurl


onMounted(() => {
  
    let formData = new FormData()
    formData.append('token', store.state.token)
    fetch(serverurl + 'validate_token', { method: 'POST', body: formData})
        .then((response) => response.json())
        .then((response_result) => {

            let { result } = response_result
            if (result == true){
                //this.login_failure = true
            } else {
                router.push({path: "/login" });
            }
        })

    })
</script>